<template>
	<view class="log_off">
		<view class="close" @click="$emit('close')">
			<image :src="`${baseImageUrl}/common/close1.png`"></image>
		</view>
		<view class="title">
			<view>注销账号</view>
		</view>
		<view class="cover">
			<image :src="career_avatar"></image>
		</view>
		<view class="tips">注销后该账号不可找回</view>
		<view class="btn_view">
			<view class="cancel" @click="submit">确认注销</view>
			<view class="confirm" @click="$emit('close')">暂不注销</view>
		</view>
	</view>
</template>

<script>
	import {
		userLogoff
	} from '@/request/api.js';
	import {
		career
	} from '@/utils/config.js';
	export default {
		data() {
			return {
				career_avatar: ""
			}
		},

		created() {
			let key = this.$store.state.info.role_id;
			if (key) {
				const item = career[key];
				this.career_avatar = item.avatar;
				// this.career_text = item.name;
			}
		},
		methods: {
			async submit() {
				await userLogoff();
				this.$u.toast("操作成功");
				setTimeout(() => {
					this.router('/pages/login/login')
				}, 1000);
			}
		}
	}
</script>

<style scoped lang="scss">
	.log_off {
		width: 688rpx;
		height: 606rpx;
		padding: 55rpx 97rpx 70rpx;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/688_606.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		position: relative;

		.close {
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			transform: translate(50rpx, -50rpx);
			z-index: 2;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			display: flex;
			justify-content: center;
			align-items: center;

			view {
				width: 256rpx;
				height: 30rpx;
				line-height: 30rpx;
				text-align: center;
				color: #494338;
				font-size: 42rpx;
				font-weight: 400;
				font-family: LiSu;
				background: url(#{$baseImageUrl}/home/title.png) no-repeat;
				background-size: 100% 100%;
			}
		}

		.cover {
			width: 120rpx;
			height: 120rpx;
			background-size: 100% 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.tips {
			text-align: center;
			color: #494338;
			font-size: 32rpx;
			font-weight: 400;
			font-family: SimSun;
		}

		.btn_view {
			width: 100%;
			display: flex;
			justify-content: center;

			view {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
				margin: 0 40rpx;
			}

			.cancel {
				background: url(#{$baseImageUrl}/common/btn2.png) no-repeat;
				background-size: 100% 100%;
			}

			.confirm {
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;
			}
		}
	}
</style>